<?php
/*
 * 1626cms 管理中心首頁
 * ============================================================================
 * 版權所有: 1626網絡，并保留所有權利。
 * 網站地址: http://www.1626.com；
 * ----------------------------------------------------------------------------
 * 這不是一個自由軟件！您只能在不用于商業目的的前提下對程序代碼進行修改和
 * 使用；不允許對程序代碼以任何形式任何目的的再發布。
 * ============================================================================
 */
define('IN_QISHI', true);
require_once('../data/config.php');
require_once('./include/admin_common.inc.php');
require_once(ADMIN_ROOT_PATH.'include/admin_settings_fun.php');
$act=!empty($_REQUEST['act']) ? trim($_REQUEST['act']) : '';

//待審核
$total_jobs="SELECT COUNT(*) AS num FROM ".table('jobs')." WHERE audit='2'";
$total_company="SELECT COUNT(*) AS num FROM ".table('company_profile')." WHERE audit='2'";
$total_resume_audit="SELECT COUNT(*) AS num FROM ".table('resume')." WHERE audit='2'";//待審核簡歷


//月新增數據
$monthdateline=time() - 30 * 24 * 3600; 
$month_total_company="SELECT COUNT(*) AS num FROM ".table('company_profile')." WHERE addtime >= $monthdateline";//本月新增
$month_total_resume="SELECT COUNT(*) AS num FROM ".table('resume')." WHERE addtime  >= $monthdateline";//本月新增
$month_total_jobs="SELECT COUNT(*) AS num FROM ".table('jobs')." WHERE addtime >= $monthdateline";//本月新增

//全部信息統計
$all_total_company="SELECT COUNT(*) AS num FROM ".table('company_profile')." WHERE 1";//本月新增
$all_total_resume="SELECT COUNT(*) AS num FROM ".table('resume')." WHERE 1";//本月新增
$all_total_jobs="SELECT COUNT(*) AS num FROM ".table('jobs')." WHERE 1";//本月新增


//$total_payment_log="SELECT COUNT(*) AS num FROM ".table('payment_log')." WHERE is_paid='1'";//待處理充值
//$total_resume_talent="SELECT COUNT(*) AS num FROM ".table('resume')." WHERE talent='3'";//待審核高級人才
//$total_resume_photo_audit="SELECT COUNT(*) AS num FROM ".table('resume')." WHERE photo_audit=2 AND photoresume=2";//待審核簡歷照片
//$total_feedback="SELECT COUNT(*) AS num FROM ".table('feedback')." ";//所有意見與建議
//$total_feedback_replyinfo="SELECT COUNT(*) AS num FROM ".table('feedback')." WHERE replyinfo='1'";//未回復意見與建議
//$total_report="SELECT COUNT(*) AS num FROM ".table('report')." ";//所有投訴信息


//每份職位空缺申請人次
$onejob_count="SELECT count(*) ascount,jobs_id,jobs_name FROM ".table('personal_jobs_apply')."  GROUP BY jobs_id ";
//每月總職位空缺申請人次
$month_apply="SELECT count(*) ascount,jobs_id,jobs_name FROM ".table('personal_jobs_apply')."  GROUP BY jobs_id  WHERE addtime >= $monthdateline";


//累積職位空缺申請人次
//申请总人数
$alluser_count="SELECT count(*) ascount,jobs_id,jobs_name FROM ".table('personal_jobs_apply')."  GROUP BY personal_uid ";
//申请总次数
$allapply_count="SELECT count(*) ascount,jobs_id,jobs_name FROM ".table('personal_jobs_apply');


//最熱門申請職位空缺及工種
//热门职位
$job_hot="SELECT count(*) ascount,jobs_id,jobs_name FROM ".table('personal_jobs_apply')."  GROUP BY jobs_id ORDER BY ascount DESC";
//热门工种
$job_category="SELECT count(*) ascount,jobs_category FROM ".table('personal_jobs_apply')."  GROUP BY jobs_category ORDER BY ascount DESC ";


//每月瀏覽及累積總次數


//申請人年齡、性別及學歷分佈
//年龄
$age_count="SELECT count(*) ascount FROM ".table('personal_jobs_apply')."  GROUP BY personal_age ";
//性别
$age_sex="SELECT count(*) ascount FROM ".table('personal_jobs_apply')."  GROUP BY personal_sex ";

//有问题，学历,学历表在 hk_resume_training
$age_sex="SELECT count(ap.personal_uid) as num, ap.personal_uid,ed.education,jobed.categoryname FROM ".table('personal_jobs_apply')." ap LEFT JOIN ".table('resume_training')." ed on ed.uid=ap.personal_uid LEFT JOIN ".table('jobs_education')." jobed ON jobed.id=ap.personal_uid GROUP BY ap.personal_uid ORDER BY ed.education DESC ";


$smarty->assign('total_jobs',get_total($total_jobs));
$smarty->assign('total_company',get_total($total_company));
$smarty->assign('total_resume_audit',get_total($total_resume_audit));
$smarty->assign('all_total_jobs',get_total($all_total_jobs));
$smarty->assign('all_total_company',get_total($all_total_company));
$smarty->assign('all_total_resume',get_total($all_total_resume));
$smarty->assign('month_total_jobs',get_total($month_total_jobs));
$smarty->assign('month_total_company',get_total($month_total_company));
$smarty->assign('month_total_resume',get_total($month_total_resume));

//$smarty->assign('total_payment_log',get_total($total_payment_log));
//$smarty->assign('total_resume_talent',get_total($total_resume_talent));
//$smarty->assign('total_resume_photo_audit',get_total($total_resume_photo_audit));
//$smarty->assign('total_feedback',get_total($total_feedback));
//$smarty->assign('total_feedback_replyinfo',get_total($total_feedback_replyinfo));
//$smarty->assign('total_report',get_total($total_report));

if($act=='')
{
	$smarty->display('admin_index.htm');
}
elseif($act=='top')
{
	$smarty->assign('site_domain',md5($_SERVER['SERVER_NAME']));
	$smarty->assign('category',get_admin_navigation());
	$smarty->assign('admin_name', $_SESSION['admin_name']);
	$smarty->display('admin_top.htm');
}
elseif($act=='left')
{
	$smarty->display('admin_left.htm');
}
elseif($act == 'main')
{
	if (file_exists('../install'))$install_warning = "您還沒有刪除 install 文件夾，出于安全的考慮，我們建議您刪除 install 文件夾。";
	if (file_exists('../update'))$update_warning = "您還沒有刪除 update 文件夾，出于安全的考慮，我們建議您刪除 update 文件夾。";
	$smarty->assign('random',mt_rand());
	$smarty->assign('install_warning',$install_warning);
	$smarty->assign('update_warning',$update_warning);
	$smarty->assign('pageheader',"管理中心 - 首頁-系统信息概览");
	$smarty->display('admin_main.htm');
}

?>
